
exports.id = 'users'
exports.install = function() {

	F.route('/', view_index);
	F.route('/contact/',view_contact);
	F.route('/hello/',plain_hello);

	F.route('/json/',plain_json);
	F.route('/mail/',redirect_mail);
	F.route('/homepage/',view_homepage);

};

function view_index() {
    var self = this;
    var users = DATABASE('users');

    users.find({}).limit(10).toArray(function(err, docs) {
        self.view('index', docs);
    });

    // or
    // users.find().limit(10).toArray(self.callback('index'));
}
function view_contact(){
	var self = this;
	self.view('contact',{email:'@'})
}
function plain_hello(){
	var self = this;
	self.plain('Hello world');
}
function plain_json(){
	var self = this;
	self.json([1,2,3,4,5])
}
function redirect_mail(){
	var self = this;
	// This function automatically reads view: email.html
    self.mail('petersirka@gmail.com', 'Test e-mail', '~email', { name: 'MODEL NAME' });
    self.redirect('/homepage/?success=1');
}
function view_homepage(){
	this.view('homepage');
}